package com.biz.primus.app.erpbridge.vo.oms;

import com.biz.primus.common.utils.Copier;
import com.biz.primus.model.oms.enums.OrderDeliveryType;
import com.biz.primus.model.oms.enums.OrderPaymentState;
import com.biz.primus.model.oms.enums.SpecialOrderMark;
import com.biz.primus.model.oms.vo.OmsConsigneeVo;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AccessLevel;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.FieldDefaults;

import java.time.LocalDateTime;

/**
 * @author yanweijin
 * @date 2017/11/26
 */

@Data
@ApiModel("pos saleorder head")
@FieldDefaults(level = AccessLevel.PRIVATE)
@NoArgsConstructor
public class SaleOrderHeader {


	@ApiModelProperty(value="订单收入oms系统的时间",dataType = "java.lang.String", example = "2017-09-12 11:12:13")
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	LocalDateTime omsCreateTime;

	@ApiModelProperty("单据编号")
	String code;

	@ApiModelProperty("单据类型")
	OrderType type;

	@ApiModelProperty(value="特殊订单活动id", notes = "例如秒杀活动,预售活动, 当标识==normal时不需要")
	String specialEventId;

	@ApiModelProperty(value = "特殊订单标识,普通订单默认为normal")
	SpecialOrderMark specialOrderMark = SpecialOrderMark.normal;

	@ApiModelProperty(value="单据状态",notes =
			"erp推送订单给oms时,只能选择outbound,finished状态,\r\n" +
					"erp推送退单给oms时,只能选择finished状态"
	)
	ErpSaleOrderState state;

	@ApiModelProperty("支付方式,返回时,取支付记录的第一行")
	String paymentWay;


	@ApiModelProperty("支付状态")
	OrderPaymentState paymentState;


	@ApiModelProperty("订单渠道")
	String channel;

	@ApiModelProperty("订单渠道文本描述")
	String channelText;

	@ApiModelProperty("订单所属门店编号")
	String depot;

	@ApiModelProperty("收银机号")
	String posNo;

	@ApiModelProperty("小票号")
	String invNo;

	@ApiModelProperty("客户备注")
	String remark;

	@ApiModelProperty("门店/客服备注")
	String selfRemark;

	@ApiModelProperty("订单/退单金额(单位分)")
	Integer amount;

	@ApiModelProperty("运费金额")
	Integer freightAmount;

	@ApiModelProperty(value="已经清算金额,订单表示已支付金额,退单表示已退款金额(单位分)")
	Integer liquidated = 0;

	@ApiModelProperty(value="订单折扣总额,退单不传(单位分)")
	Integer discountAmount = 0;

	@ApiModelProperty(value="使用积分总数")
	Integer usePoint;

	@ApiModelProperty(value="客户电话")
	String mobile;

	@ApiModelProperty(value="客户昵称")
	String nickname;

	@ApiModelProperty(value="客户等级")
	Long userLevel;

	@ApiModelProperty(value="配送方式")
	OrderDeliveryType deliverType;

	@ApiModelProperty(value="快递公司")
	String expectedExpressProvider;

	@ApiModelProperty(value="快递公司名称")
	String expectedExpressProviderText;

	@ApiModelProperty(value="快递单号")
	String expressNumber;

	@ApiModelProperty(value="销售时间")
	String saleTime;

	@ApiModelProperty(value="配送时效",allowableValues = "in19m,in29m,in59m")
	String deliveryTimeliness;

	@ApiModelProperty(value="收银员员工号")
	String checker;

	@ApiModelProperty(value="如果是退单,表示退单所属的原订单号")
	String originOrderCode;

	@ApiModelProperty(value="促销折扣(单位分)")
	Integer discountPop = 0;

	@ApiModelProperty(value="临时折扣(单位分)")
	Integer discountGrant = 0;

	@ApiModelProperty(value="券折扣(单位分)")
	Integer discountCoupon = 0;

	@ApiModelProperty(value="收货信息")
	OmsConsigneeVo consignee;

	@ApiModelProperty("退货收货人编号")
	String receiver;

	@ApiModelProperty(value="退货收货时间,yyyy-MM-dd HH:mm:ss",dataType = "java.lang.String", example = "2017-11-02 12:11:10")
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
	LocalDateTime receiveTime;

	public SaleOrderHeader(SaleOrder saleOrder){
		Copier.from(saleOrder).to(this);
	}


}
